<?php

namespace login\view;

class HTMLView {
	/**
	 * @var string
	 */
	private $logginInfo;
	/**
	 * @var string
	 */
	private $inputValue;
	/**
	 * @var string
	 */
	private $registerInfo;
	/**
	 * @var string
	 */
	private $registerValue;

	private static $newUserName = "NewUserName";
	
	/**
	 * @param $info string
	 */
	public function setLogginInfo($info) {
		$this->logginInfo = $info;
	}

	public function setInputValue() {
		$this->inputValue = $_POST["uName"];
	}

	public function setLogoutMessage() {
		$this->logginInfo = "Du har loggat ut";
	}

	public function setRegisterValue() {
		$this->registerValue = $_POST[self::$newUserName];
	}

	public function setErrorMessage($message) {
		if($message == "1") {
			$this->registerInfo = "Användarnamn saknas.";
		} else if($message == "2") {
			$this->registerInfo = "Lösenord saknas.";
		} else if($message == "3") {
			$this->registerInfo = "Användaruppgifterna innehåller en tag.";
		}
	}

	public function setUserExistsMessage() {
		$this->registerInfo = "Användarnamn upptaget.";
	}

	/**
	 * @return string HTML
	 */
	public function getLoginPage() {
		return "<!DOCTYPE HTML SYSTEM>
		<html>
			<head>
				<title>Quizzer, Inte inloggad</title>
				<meta charset='UTF-8'>
			</head>
			<body>
				<div class='wrapper'>
					<div class='leftBox'>
						<h1>Quizzer</h1>
						<form action='?login' method='post'>
							<p>Skriv in användarnamn och lösenord</p>
							<strong><p>$this->logginInfo</p></strong>
							<lable for='uName'>Användarnamn: </lable><br>
							<input type='text' id='uName' name='uName' value='$this->inputValue'><br>
							<lable for='password'>Lösenord: </lable><br>
							<input type='password' id='password' name='pWord'><br>
							<input type='submit' value='Logga in' class='submitLeft'>
						</form>
						<a href='?register'>Registrera dig</a>
					</div>

					<div class='mainContent'>
						<br>
					</div>
				</div>
			</body>
		</html>";
	}
	/**
	 * @return string HTML
	 */
	public function getRegisterPage() {
		return "<!DOCTYPE HTML SYSTEM>
		<html>
			<head>
				<title>Laboration 1, Inte inloggad</title>
				<meta charset='UTF-8'>
			</head>
			<body>
				<div class='wrapper'>
					<div class='leftBox'>
						<h1>Quizzer</h1>
						<a href='?'>Tillbaka</a>
					</div>

					<div class='mainContent'>
						<br>
						<p><strong>$this->registerInfo</strong></p>
						<form action='?adduser' method='post'>
							<label for='NewUserNameID'>Användarnamn: </label>
							<input class='add' type='text' size='20' name='NewUserName' id='NewUserNameID' value='$this->registerValue' />
							<label for='NewPasswordID' >Lösenord  :</label>
							<input class='add' type='password' size='20' name='NewPassword' id='NewPasswordID' />
							<input class='button' type='submit' value='Skicka' />
						</form>
					</div>
				</div>
			</body>
		</html>";
	}
}